import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;  

public class DBUtil {  
    public static final String url = "jdbc:mysql://127.0.0.1/ipdb";  
    public static final String name = "com.mysql.jdbc.Driver";  
    public static final String user = "root";  
    public static final String password = "root";  
  
    public Connection conn;  

	public Connection getConn(){
    	 try {
		    Class.forName(name); 
			conn = DriverManager.getConnection(url, user, password);
			
			return conn;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	 catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	return null;
    }
	
	public static void main(String []arge){
		DBUtil db = new DBUtil();
		db.conn = db.getConn();
		System.out.println(db.conn);
	}
}  
